import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/material.dart';
import 'package:sainbainu/common/values/colors.dart';

/// 媒体表单容器
class OutlinedFormBox extends StatelessWidget {
  const OutlinedFormBox({
    super.key,
    required this.child,
    this.icon,
    this.iconChild,
    this.rightIcon,
    this.padding = const EdgeInsets.all(10),
    this.onTap,
  });

  final Widget? iconChild;
  final String? icon;
  final Widget child;
  final Widget? rightIcon;
  final EdgeInsetsGeometry padding;
  final VoidCallback? onTap;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        decoration: const BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.all(Radius.circular(8)),
        ),
        margin: const EdgeInsets.only(bottom: 15),
        child: DottedBorder(
          dashPattern: const [4, 2],
          borderType: BorderType.RRect,
          radius: const Radius.circular(8),
          color: AppColors.border,
          child: Padding(
            padding: padding,
            child: Row(
              children: [
                if (iconChild != null) iconChild!,
                if (icon != null)
                  Image.asset(
                    icon!,
                    width: 24,
                    height: 24,
                  ),
                Expanded(child: child),
                if (rightIcon != null) rightIcon!,
              ],
            ),
          ),
        ),
      ),
    );
  }
}
